package fr.upstlse.glre.client.vitrine.editeurDePage;

import net.mygwt.ui.client.Events;
import net.mygwt.ui.client.Style;
import net.mygwt.ui.client.event.BaseEvent;
import net.mygwt.ui.client.event.Listener;
import net.mygwt.ui.client.widget.Button;
import net.mygwt.ui.client.widget.ContentPanel;
import net.mygwt.ui.client.widget.Dialog;
import net.mygwt.ui.client.widget.Info;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.BorderLayout;
import net.mygwt.ui.client.widget.layout.BorderLayoutData;

import com.google.gwt.user.client.ui.HorizontalPanel;

public class Editeur {

//	private Panel panel;
//	private Window window;
//	private Panel navPanel;
//	private TabPanel tabPanel;

//	public Editeur() {
//	panel = new Panel();  
//	panel.setBorder(false);  
//	panel.setPaddings(15);  

//	//center panel  
//	tabPanel = new TabPanel();














//	Panel panel = new Panel();  
//	panel.setBorder(false);  
//	panel.setPaddings(15);  

//	//create the FormPanel and set the label position to top  
//	FormPanel formPanel = new FormPanel();  
//	formPanel.setFrame(true);  
//	formPanel.setTitle("Multi Column, Nested Layouts and Anchoring");  
//	formPanel.setPaddings(5, 5, 5, 0);  
//	formPanel.setWidth(600);  
//	formPanel.setLabelAlign(Position.TOP);  

//	//create a top panel with 2 columns (ColumnLayout). Create a Panel for the first column  
//	//with layout FormLayout and add the fields for the first column. Then create a second  
//	//Panel with FormLayout and add fields to the sencond panel. Finally add the first and  
//	//second panel to the top panel which lays them out in columns since it has a ColumnLayout  
//	//assigned to it.  

//	//create top panel with ColumnLayout  
//	Panel topPanel = new Panel();  
//	topPanel.setLayout(new ColumnLayout());  

//	//create first panel and add fields to it  
//	Panel columnOnePanel = new Panel();  
//	columnOnePanel.setLayout(new FormLayout());  

//	TextField firstName = new TextField("First Name", "first");  
//	columnOnePanel.add(firstName, new AnchorLayoutData("95%"));  

//	TextField company = new TextField("Company", "company");  
//	columnOnePanel.add(company, new AnchorLayoutData("95%"));  

//	//add first panel as first column with 50% of the width  
//	topPanel.add(columnOnePanel, new ColumnLayoutData(.5));  

//	//create second panel and add fields to it  
//	Panel columnTwoPanel = new Panel();  
//	columnTwoPanel.setLayout(new FormLayout());  

//	TextField lastName = new TextField("Last Name", "last");  
//	columnTwoPanel.add(lastName, new AnchorLayoutData("95%"));  

//	TextField email = new TextField("Email", "email");  
//	email.setVtype(VType.EMAIL);  
//	columnTwoPanel.add(email, new AnchorLayoutData("95%"));  

//	//add the second panel as the second column to the top panel to take up the other 50% width  
//	topPanel.add(columnTwoPanel, new ColumnLayoutData(0.5));  
//	formPanel.add(topPanel);  

//	//add a HtmlEditor below the 2-column top panel  
//	HtmlEditor htmlEditor = new HtmlEditor("Biography", "bio");  
//	htmlEditor.setHeight(200);  
//	formPanel.add(htmlEditor, new AnchorLayoutData("98%"));  

//	//add a couple of buttons to the form  
//	formPanel.addButton(new Button("Save"));  
//	formPanel.addButton(new Button("Cancel"));  
//	panel.add(formPanel);


//	tabPanel.add(panel);










//	//west panel  
//	navPanel = new Panel();  
//	navPanel.setTitle("Pages du site");  
//	navPanel.setWidth(200);

//	BorderLayoutData centerData = new BorderLayoutData(RegionPosition.CENTER);  
//	centerData.setMargins(3, 0, 3, 3);  

//	BorderLayoutData westData = new BorderLayoutData(RegionPosition.WEST);  
////	westData.setSplit(true);  
//	westData.setMargins(3, 3, 0, 3);  
//	westData.setCMargins(3, 3, 3, 3);  

//	window = new Window();  
//	window.setTitle("Editeur de pages WEB");  
//	window.setClosable(true);  
//	window.setWidth(800);  
//	window.setHeight(600);  
//	window.setPlain(true);  
//	window.setModal(true);
//	window.setLayout(new BorderLayout());  
//	window.add(tabPanel, centerData);  
//	window.add(navPanel, westData);  
//	window.setCloseAction(Window.CLOSE);  


//	String[] pages = KitchenSink.getPages();
//	for (int i = 0; i < pages.length; i=i+2) {
//	ajouterUnePage(pages[i],pages[i+1]);
//	}

//	} 

//	public void ajouterUnePage(final String titreOnglet, final String contenu){
//	Label lab = new Label(titreOnglet);
//	navPanel.add(lab);
//	lab.addClickListener(new ClickListener(){
//	public void onClick(Widget sender) {				
//	if(tabPanel.getComponent(titreOnglet)==null){
////	Panel centerPanelAgenda = new HTMLPanel();

////	HtmlEditor html = new HtmlEditor();
//////html.setValue("coucou");

////	centerPanelAgenda.add(html);
////	centerPanelAgenda.setId(titreOnglet);
////	centerPanelAgenda.setTitle(titreOnglet);
////	centerPanelAgenda.setAutoScroll(true);
////	centerPanelAgenda.setClosable(true);

////	tabPanel.add(centerPanelAgenda);
////	tabPanel.activate(titreOnglet);

//	}
//	else
//	tabPanel.activate(titreOnglet);

//	}
//	});
	
	final Dialog dialog;
	
	public Editeur() {
		dialog = new Dialog(Style.YES_NO | Style.CLOSE);  
		dialog.setCloseOnButtonClick(true);  
		dialog.setText("Dialog");  
		dialog.addListener(Events.Close, new Listener() {  

			public void handleEvent(BaseEvent be) {  
				Button btn = dialog.getButtonPressed();  
				if (btn != null) {  
					Info.show("Button Pressed", "The {0} was pressed.", btn.getText());  
				}  
			}  

		});  
		dialog.getContent().setHeight(50);  
		dialog.getContent().addText("This is the dialogs content area.");  

		final Dialog complex = new Dialog(Style.OK | Style.CLOSE | Style.RESIZE);  
		complex.setMinimumSize(300, 200);  
		complex.addStyleName("my-shell-plain");  
		complex.setText("Nested BorderLayout");  
		complex.addListener(Events.Close, new Listener() {  

			public void handleEvent(BaseEvent be) {  
				Button btn = complex.getButtonPressed();  
				if (btn != null) {  
					Info.show("Button Pressed", "The {0} was pressed.", btn.getText());  
				}  
			}  

		});  

		BorderLayout layout = new BorderLayout();  
		layout.setMargin(0);  

		WidgetContainer c = complex.getContent();  
		c.setBorders(false);  
		c.setLayout(layout);  

		ContentPanel west = new ContentPanel(Style.HEADER);  
		west.setText("West");  

		ContentPanel center = new ContentPanel(Style.HEADER);  
		center.setText("Center");  

		c.add(west, new BorderLayoutData(Style.WEST, 125, 100, 300));  
		c.add(center, new BorderLayoutData(Style.CENTER));  

		complex.setSize(375, 250);  

		HorizontalPanel hp = new HorizontalPanel();  
		hp.setSpacing(10);  

		complex.open(); 
	}
}
